package com.hmall.order.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author Ms SUN
 * @date 2023/5/15
 */
@Slf4j
@Component
public class ObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("开始公共字段填充。。。createTime");
        //创建时间
        Date now = new Date();
        metaObject.setValue("createTime", now);
        //更新时间
        metaObject.setValue("updateTime", now);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("开始公共字段填充。。。updateTime");
        //更新时间
        Date now = new Date();
        metaObject.setValue("updateTime", now);
    }
}
